//package cn.jiyun.schedule;
//
//import cn.jiyun.util.DateUtils;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.scheduling.annotation.Scheduled;
//import org.springframework.stereotype.Component;
//
//import java.time.LocalDate;
//import java.time.temporal.ChronoUnit;
//import java.util.Date;
//import java.util.List;
//
//@Component
//public class TaskDemo {
//    @Autowired
//    CarMapper carMapper;
//    /**
//     * 定时任务方法，一秒钟执行一次
//     */
//    @Scheduled(cron = "*/1 * * * * ?")
//    public void execute(){
//        List<Car> carList = carMapper.selectList(null);
//        System.out.println("执行定时任务了");
//        for (Car car : carList) {
//            LocalDate startLocaldate = DateUtils.dateToLocalDate(new Date());
//            LocalDate endLocaldate = DateUtils.dateToLocalDate(car.getEnddate());
//            long remaindays = startLocaldate.until(endLocaldate, ChronoUnit.DAYS);
//            car.setRemaindays((int) remaindays);//计算两个日期之间的天数
//            carMapper.updateById(car);
//        }
//
//
//
//    }
//}
